package com.solute.utils.services.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import com.solute.domain.TagVO;

@Component
public interface TagDao {
	@Insert({
		"insert into tags (",
		"   id",
		"  ,tag",
		") VALUES (",
		"   #{id}  /* id - IN varchar(36) */",
		"  ,#{tag}  /* tag - IN varchar(256) */",
		")"})
	public <T> void insertTag(T param);
	
	@Select({
		"SELECT id, tag",
		"  FROM tags",
		" WHERE tag = #{tag}"
	})
	public <T> TagVO selectTagByTag(T tag);
	
	@Select({
		"select count(*) from tags"
	})
	public <T> int selectNumTags();
	
	@Select({
		"select count(*) from tag_group"
	})
	public <T> int selectNumTagGroups();
	
	@Insert({
		"insert into tag_group (",
		"   gid",
		"  ,tag_id",
		") VALUES (",
		"   #{gid}  /* gid - IN varchar(36) */",
		"  ,#{tagId}  /* tag_id - IN varchar(36) */",
		")"})
	public <T> void insertTagGroup(T param);
	
	@Delete({
		"delete from tag_group"
	})
	public void deleteTagGroups();
	
	@Delete({
		"delete from tags"
	})
	public void deleteTags();
}
